package com.stx.test;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.Scanner;

/**
 * packageName com.stx.test
 *
 * @author YangYi
 * @className CarCardLimit
 * @date 2025/9/5
 * @description TODO
 */
public class CarCardLimit {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
//        LocalDate nowDate = LocalDate.now();
        System.out.println("请输入日期（格式：YYYY-MM-DD）：" );
        String date = scanner.next();
        LocalDate nowDate = LocalDate.parse(date);
        DayOfWeek dayOfWeek = nowDate.getDayOfWeek();
        System.out.println("今天是" + dayOfWeek);
        System.out.println("请输入检查的车牌号：");
        String carCard = scanner.next();
        if (carCard.length() == 8) {
            System.out.println("新能源车不受限制，可以通行");
        } else if (carCard.length() == 7) {
            for (int i = carCard.length()-1; i >= 0; i--) {
                char card_num = carCard.charAt(i);
                System.out.println("车牌第" + i + "位是：" + card_num);
                // 需要判断是否为数字
                if(Character.isDigit(card_num)){
                    int num = Character.getNumericValue(card_num);
                    switch (dayOfWeek) {
                        case MONDAY: {
                            if (1 == num || 6 == num) {
                                System.out.println(carCard + "今天限行");
                            }
                            break;
                        }
                        case TUESDAY: {
                            if (2 == num || 7 == num) {
                                System.out.println(carCard + "今天限行");
                            }
                            break;
                        }
                        case WEDNESDAY: {
                            if (3 == num || 8 == num) {
                                System.out.println(carCard + "今天限行");
                            }
                            break;
                        }
                        case THURSDAY: {
                            if (4 == num || 9 == num) {
                                System.out.println(carCard + "今天限行");
                            }
                            break;
                        }
                        case FRIDAY: {
                            if (5 == num || 0 == num) {
                                System.out.println(carCard + "今天限行");
                            }
                            break;
                        }
                        default: {
                            System.out.println(carCard + "今天不限行");
                            break;
                        }
                    }
                }
            }
        } else {
            System.out.println("车牌输入长度有误，请重新输入！");
        }
    }
}
